/* Ejerxice 5.24
   ejer5_24.c */
#include <stdio.h>

/* Prototypes */
int fahrenheit( int celcius );
int celcius( int fahrenheit );

/* function main begins program execution */
int main( void )
{
    int c, f;

    // Celcius to Fahrenheit
    printf("%10s%15s\n", "Celcius", "Fahrenheit");

    for ( c = 0; c <= 100; c++ )
        printf("%10d%15d\n", c, fahrenheit( c ));

    // Fahrenheit to Celcius
    printf("%15s%10s\n", "Fahrenheit", "Celcius");
    for ( f = 32; f <= 212; f++ )
        printf("%15d%10d\n", f, celcius( f ));
	return 0; /* indicate that program ended successfully */
} /* end function main */

/* converts celcius to fahrenheit */
int fahrenheit( int celcius )
{
    return 9 * celcius / 5 + 32;
} /* end function celcius2Fahrenheit */

/* converts fahrenheit to celcius */
int celcius( int fahrenheit )
{
    return 5 * ( fahrenheit - 32 ) / 9;
} /* end function fahrenheit2Celcius */
